<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title><%= title %></title>
    <script src="/vue.js"></script>
    <script src="http://127.0.0.1:8888/socket.io/socket.io.js"></script>
</head>
<body>
    <div>
        <input type="text" id="msg" value="beyond is number one!" />
        <button onclick="sendMsg()">send</button>
    </div>
    <div id="output"></div>
</body>
</html>
<script>
    // ---------创建连接-----------
    var socket = io.connect();

    var room = location.pathname.split('/');

    socket.on('data', function () {
    });

    socket.on('room', function (data) {
        console.log('欢迎：', data)
    });

    function sendMsg() {
        const msg = document.getElementById("msg").value;
        socket.emit('room', {
            room: room[room.length - 1],
            user: msg
        })
    }
</script>